//
// *  $Id: TestFileHeader.java,v 1.2 2003/09/21 15:49:02 boisvert Exp $
// *
// *  Unit tests for FileHeader class
// *
// *  Simple db toolkit
// *  Copyright (C) 1999, 2000 Cees de Groot <cg@cdegroot.com>
// *
// *  This library is free software; you can redistribute it and/or
// *  modify it under the terms of the GNU Library General Public License 
// *  as published by the Free Software Foundation; either version 2 
// *  of the License, or (at your option) any later version.
// *
// *  This library is distributed in the hope that it will be useful,
// *  but WITHOUT ANY WARRANTY; without even the implied warranty of
// *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
// *  Library General Public License for more details.
// *
// *  You should have received a copy of the GNU Library General Public License 
// *  along with this library; if not, write to the Free Software Foundation, 
// *  Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
// 

//*************************************************************************
//**  Included in JDMB 1.0 port to SharpDBM;  11/2013 Cyrus Neah cneah@codingreal.com
//**  SharpDBM is an independent reimplementation of the JDBM 1.0 software library  
//*************************************************************************

using SharpDBM;
using SharpDBM.recman;
using SharpDBM.helper;
using SharpDBM.btree;



namespace SharpDBM.Test

.recman
{

	using NUnit.Framework;

///
// *  This class contains all Unit tests for {@link FileHeader}.
// 
    [TestFixture]
    public class TestFileHeader  
	{

		

//    *
//     *  Test set, write, read
//     
 
		[Test]
		public virtual void testSetWriteRead()
		{
	  BlockIo b = new BlockIo(0, new sbyte[1000]);
	  FileHeader f = new FileHeader(b, true);
	  for (int i = 0; i < Magic.NLISTS; i++)
	  {
		  f.setFirstOf(i, 100 * i);
		  f.setLastOf(i, 200 * i);
	  }

	  f = new FileHeader(b, false);
	  for (int i = 0; i < Magic.NLISTS; i++)
	  {
		  NUnit.Framework.Assert.AreEqual(i * 100, f.getFirstOf(i), "first " + i);
		  NUnit.Framework.Assert.AreEqual(i * 200, f.getLastOf(i), "last " + i);
	  }
		}

//    *
//     *  Test root rowids
//     
 
	[Test]
		public virtual void testRootRowids()
		{
	  BlockIo b = new BlockIo(0, new sbyte[RecordFile.BLOCK_SIZE]);
	  FileHeader f = new FileHeader(b, true);
	  for (int i = 0; i < FileHeader.NROOTS; i++)
	  {
		  f.setRoot(i, 100 * i);
	  }

	  f = new FileHeader(b, false);
	  for (int i = 0; i < FileHeader.NROOTS; i++)
	  {
		  NUnit.Framework.Assert.AreEqual(i * 100, f.getRoot(i), "root " + i);
	  }
		}

//    *
//     *  Runs all tests in this class
//     
		static void Main(string[] args)
		{
	  //textui.TestRunner.run(new TestSuite(typeof(TestFileHeader)));
		}
	}

}